
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>DataTable + DataSource.IO + XML Data</title>

<style type="text/css">
/*margin and padding on body element
  can introduce errors in determining
  element position and are not recommended;
  we turn them off as a foundation for YUI
  CSS treatments. */
body {
	margin:0;
	padding:0;
}
</style>

<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" />
<script type="text/javascript" src="../../build/yui/yui-min.js"></script>


<!--begin custom header content for this example-->
<style type="text/css">
/* custom styles for this example */
.dt-example {margin:1em;}

/* css to counter global site css */
.dt-example th {text-transform:none;}
.dt-example table {width:auto;}
.dt-example caption {display:table-caption;}
</style>
<!--end custom header content for this example-->

</head>

<body class="yui3-skin-sam  yui-skin-sam">

<h1>DataTable + DataSource.IO + XML Data</h1>

<div class="exampleIntro">
	<p>This example shows how to populate a DataTable with data from the Yahoo! Local webservice retrieved via a same-domain PHP proxy. First we create a DataSource.IO instance pointing to the proxy, then using the DataTableDataSource plugin we can load data for Chinese restaurants near our office.</p>

<p>In this example, we set the <code>initialRequest</code> value in the DataTableDataSource plugin constructor so that the initial data is loaded first and then the DataTable is rendered in a separate call.</p>

<p><strong>Note:</strong> XML parsing currently has known issues on the Android WebKit browser.
			
</div>

<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

<div id="chinese" class="dt-example"></div>

<script type="text/javascript">
YUI({ filter: 'raw' }).use("datasource-io", "datasource-xmlschema", "datatable-base", "datatable-datasource", function (Y) {
    var cols = ["Title", "Phone", "Rating"];
    ds = new Y.DataSource.IO({
        source:"assets/php/ylocal_proxy.php?"})
        .plug(Y.Plugin.DataSourceXMLSchema, {
            schema: {
                resultListLocator: "Result",
                resultFields: [{key:"Title", locator:"*[local-name() ='Title']"},
                    {key:"Phone", locator:"*[local-name() ='Phone']"},
                    {key:"Rating", locator:"*[local-name()='Rating']/*[local-name()='AverageRating']"}]
            }
        }),
    dt = new Y.DataTable.Base({columnset:cols, summary:"Chinese restaurants near 98089", caption:"Table with XML data from same-domain script"})
        .plug(Y.Plugin.DataTableDataSource, {datasource:ds, initialRequest:"zip=94089&query=chinese"});

    ds.after("response", function() {
        dt.render("#chinese")}
    );
});
</script>

<!--END SOURCE CODE FOR EXAMPLE =============================== -->

</body>
</html>
